package com.hiyee.platform.service.impl;

import com.github.pagehelper.PageHelper;
import com.hiyee.platform.response.PageListResult;
import com.hiyee.platform.mapper.AmapCityWeatherMapper;
import com.hiyee.platform.pojo.AmapCityWeather;
import com.hiyee.platform.pojo.bo.WeatherListBO;
import com.hiyee.platform.service.BaseService;
import com.hiyee.platform.service.WeatherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

@Service
public class WeatherServiceImpl extends BaseService implements WeatherService {

    @Autowired
    private AmapCityWeatherMapper amapCityWeatherMapper;

    @Override
    public PageListResult getList(WeatherListBO weatherListBO) {
        Example example = new Example(AmapCityWeather.class);
        Example.Criteria criteria = example.createCriteria();
        criteria.andEqualTo("type", weatherListBO.getType());
        PageHelper.startPage(weatherListBO.getPage(), weatherListBO.getPageSize());
        List<AmapCityWeather> dataList = amapCityWeatherMapper.selectByExample(example);
        return this.generaPageList(dataList);
    }
}
